VOISEditor =
{
    loadingSectionId : new String("awwwe-browser-vois-wizard-form-loading-section"),
    loadedSectionId : new String("awwwe-browser-vois-wizard-form-loaded-section"),
    
	form : null,
	formId : new String("awwwe-browser-vois-wizard-form-"),
	formIndex : new Number(0),
    formSiteURlId : new String("awwwe-browser-vois-wizard-form-siteurl"),
    formSiteNameSayasId : new String("awwwe-browser-vois-wizard-form-sitname-sayas"),
    formLinkOffSiteId : new String("awwwe-browser-vois-wizard-form-link-offsite"),
    formSpellUpperCaseId : new String("awwwe-browser-vois-wizard-form-spell-upper-case"),
    formIndexList : [],
	selectedDivClassName : new String("awwwe-browser-vois-wizard-form-div-selected"),
    selectedInnerDivClassName : new String("awwwe-browser-vois-wizard-form-inner-div-selected"),
	unSelectedDivClassName : new String("awwwe-browser-vois-wizard-form-div-unselected"),
    unSelectedInnerDivClassName : new String("awwwe-browser-vois-wizard-form-inner-div-unselected"),
    
    markupUnSelectedClassName : new String("awwwe-browser-vois-wizard-markup-unselected"),
    markupSelectedClassName : new String("awwwe-browser-vois-wizard-markup-selected"),
    markupInlineClassName : new String("awwwe-browser-vois-wizard-markup-inline"),

	wrapperDivId : new String("awwwe-browser-vois-wizard-web-page-wrapper-div"),
    wrapperWorkAreaDivId : new String("awwwe-browser-vois-wizard-web-page-wrapper-div-workarea"),
    
    // vois markup output for copy
    voisMarkupOutputDivId : new String("awwwe-browser-vois-wizard-markup-output-div"),
    voisMarkupOutputCopyId : new String("awwwe-browser-vois-wizard-markup-output-copy"),
    // vois markup save button
    voisMarkupSaveButtonId : new String("awwwe-browser-vois-wizard-markup-save-button"),

	currentlySelectedNode : null,
    currentlyUsedNode : null,
	unSelectedControlClassName : new String("awwwe-browser-vois-wizard-form-unselected-control"),
	selectedControlClassName : new String("awwwe-browser-vois-wizard-form-selected-control"),
    currentlySelectedFormIndex : null,

    floatRightClassName : new String("awwwe-browser-vois-wizard-float-right"),
    upperDivClassName : new String("awwwe-browser-vois-wizard-form-section-upper-div"),
    
    removeConfirmationTimeout : null,
    
    alerting : false,


	Label : function(whatFor, text, id)
	{
		var label = document.createElement("label");
		label.setAttribute("htmlFor", whatFor);
        label.setAttribute("for", whatFor);
        if (id != null)
        {
            label.setAttribute("id", id);
        }
		label.innerHTML = text;
		return label;
	},
    
    ExtractSectionIndexFromId : function(id)
    {
        var index, shortId, i;
        if (id == undefined)
        {
        	index = "";
        }
        else
        {
            shortId = id.substring(VOISEditor.formId.length);
            i = shortId.indexOf("-");
            if (i > 0)
            {
                index = shortId.substring(0, i);
            }
            else
            {
                index = "";
            }
        }
        return index;
    },

    BuildExpandSectionButtonId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-expand-section-button";
    },

    BuildUnExpandSectionButtonId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-unexpand-section-button";
    },

    BuildRemoveSectionButtonId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-remove-section-button";
    },

    BuildSectionDivId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-section-div";
    },
    
    BuildSectionTitleId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-section-title";
    },
    
    BuildFormIndexFromSectionDivId : function(sId)
    {
        return sId.replace(VOISEditor.formId, "").replace("-section-div", "");
    },
    
    BuildFormIndexFromTitleAtDivId : function(sId)
    {
        return sId.replace(VOISEditor.formId, "").replace("-titleat", "");
    },

    BuildSectionInnerDivId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-section-inner-div";
    },

    BuildEnterDescriptionId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-comment";
    },

    BuildOpenWithMovieId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-open-with-movie";
    },
    
    BuildIsMainContentId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-is-main-content";
    },

    BuildSelectTypeId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-type";
    },

    BuildConditiontId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-condition";
    },
    
    BuildNeverSpeakAtPId : function (index)
    {
        return VOISEditor.formId + index.toString() + "-neverspeakat-p";
    },

    BuildOnlySpeakAtLabelId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-onlyspeakat-label";
    },

    BuildEnterOnlySpeakAtId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-onlyspeakat";
    },

    BuildEnterNeverSpeakAtId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-neverspeakat";
    },

    BuildEnterTitleAtId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-titleat";
    },

    BuildEnterTitleId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-title";
    },
    
    BuildUpSectionButtonId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-up";
    },
    
    BuildDownSectionButtonId : function(index)
    {
        return VOISEditor.formId + index.toString() + "-down";
    },

    SectionExpand : function(formIndex)
    {
        var i, id, node;

        // if a control was selected then unselect it
        VOISEditor.ControlUnSelect();

        // show this inner div
        sId = VOISEditor.BuildSectionInnerDivId(formIndex);
		node = document.getElementById(sId);
        node.style.display = "block";
        node.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);

        // hide the expand button
        node = document.getElementById(VOISEditor.BuildExpandSectionButtonId(formIndex));
        node.style.visibility = "hidden";

        // show the unexpand button
        node = document.getElementById(VOISEditor.BuildUnExpandSectionButtonId(formIndex));
        node.style.visibility = "visible";

        // close the other inner divs
        for (i=0; i<VOISEditor.formIndex; i++)
        {
    		id = VOISEditor.BuildSectionInnerDivId(i);
            if (id != sId)
            {
                node = document.getElementById(id);
                if (node != null)
                {
                    VOISEditor.SectionUnExpandUnSelect(i);
                }
            }
        }
    },

    SectionUnExpand : function(formIndex)
    {
        var i, id, node;

        // if a control was selected then unselect it
        VOISEditor.ControlUnSelect();

        // un show this inner div
        sId = VOISEditor.BuildSectionInnerDivId(formIndex);
		node = document.getElementById(sId);
        node.style.display = "none";
        node.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);

        // hide the expand button
        node = document.getElementById(VOISEditor.BuildExpandSectionButtonId(formIndex));
        node.style.visibility = "visible";

        // show the un expand button
        node = document.getElementById(VOISEditor.BuildUnExpandSectionButtonId(formIndex));
        node.style.visibility = "hidden";

        // unselect this section
        node.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
    },

    SectionUnExpandUnSelect : function(formIndex)
    {
        var node;

        // un show this inner div
		node = document.getElementById(VOISEditor.BuildSectionInnerDivId(formIndex));
        node.style.display = "none";
        node.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);

        // hide the expand button
        node = document.getElementById(VOISEditor.BuildExpandSectionButtonId(formIndex));
        node.style.visibility = "visible";

        // show the un expand button
        node = document.getElementById(VOISEditor.BuildUnExpandSectionButtonId(formIndex));
        node.style.visibility = "hidden";
    },
    
    SectionIndex : function(sId)
    {
        var formId = VOISEditor.BuildFormIndexFromSectionDivId(sId);
        return VOISEditor.formIndexList.indexOf(formId);
    },
    
    SectionSetUpDownButtons : function()
    {
        var i, formIndex, id, node;
        if (VOISEditor.formIndexList.length > 0)
        {
            if (VOISEditor.formIndexList.length == 1)
            {
                // turn all buttons off
                formIndex = VOISEditor.formIndexList[0];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
            }
            else
            {
                var lastDownButtonId = "";
                // top section - up = off down = on
                formIndex = VOISEditor.formIndexList[0];
                id = VOISEditor.BuildSectionDivId(formIndex);
                node = document.getElementById(id);
                if (node.style.display == "block")
                {
                    id = VOISEditor.BuildUpSectionButtonId(formIndex);
                    node = document.getElementById(id);
                    node.style.display = "none";
                    id = VOISEditor.BuildDownSectionButtonId(formIndex);
                    lastDownButtonId = id;
                    node = document.getElementById(id);
                    node.style.display = "inline";
                }
                
                // middle and last both on
                for (i=1; i<VOISEditor.formIndexList.length; i++)
                {
                    formIndex = VOISEditor.formIndexList[i];
                    id = VOISEditor.BuildSectionDivId(formIndex);
                    node = document.getElementById(id);
                    if (node.style.display == "block")
                    {
                        id = VOISEditor.BuildUpSectionButtonId(formIndex);
                        node = document.getElementById(id);
                        node.style.display = "inline";
                        id = VOISEditor.BuildDownSectionButtonId(formIndex);
                        lastDownButtonId = id;
                        node = document.getElementById(id);
                        node.style.display = "inline";
                    }
                }

                // set the down button on the last section visible
                if (lastDownButtonId.length > 0)
                {
                    node = document.getElementById(lastDownButtonId);
                    node.style.display = "none";
                }
            }
        }
    },
    
    SectionSetUpDownButtonsAtEnd : function()
    {
        var formIndex, id, node;
        if (VOISEditor.formIndexList.length > 0)
        {
            if (VOISEditor.formIndexList.length == 1)
            {
                // turn all buttons off
                formIndex = VOISEditor.formIndexList[0];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
            }
            else if (VOISEditor.formIndexList.length == 2)
            {
                // second last section - up = off down = on
                formIndex = VOISEditor.formIndexList[VOISEditor.formIndexList.length-2];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "inline";

                // last section - up = on down = off
                formIndex = VOISEditor.formIndexList[VOISEditor.formIndexList.length-1];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "inline";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
            }
            else
            {
                // second last section - up = on down = on
                formIndex = VOISEditor.formIndexList[VOISEditor.formIndexList.length-2];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "inline";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "inline";

                // last section - up = on down = off
                formIndex = VOISEditor.formIndexList[VOISEditor.formIndexList.length-1];
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "inline";
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                node = document.getElementById(id);
                node.style.display = "none";
            }
        }
    },
    
    SectionUp : function(sFormIndex)
    {
        var dFormIndex;
        var i;
        i = VOISEditor.formIndexList.indexOf(sFormIndex);
        i--;
        while (i >= 0)
        {
            dFormIndex = VOISEditor.formIndexList[i];
            var id = VOISEditor.BuildSectionDivId(dFormIndex);
            var dNode = document.getElementById(id);
            if (dNode.style.display == "block")
            {
                VOISEditor.SectionSwap(sFormIndex, dFormIndex);
                break;
            }
            else
            {
                i--;
            }
        }
    },
    
    SectionDown : function(sFormIndex)
    {
        var dFormIndex;
        var i;
        i = VOISEditor.formIndexList.indexOf(sFormIndex);
        i++;
        while (i < VOISEditor.formIndexList.length)
        {
            dFormIndex = VOISEditor.formIndexList[i];
            var id = VOISEditor.BuildSectionDivId(dFormIndex);
            var dNode = document.getElementById(id);
            if (dNode.style.display == "block")
            {
                VOISEditor.SectionSwap(sFormIndex, dFormIndex);
                break;
            }
            else
            {
                i++;
            }
        }
    },
    
    SectionSwap : function(sFormIndex, dFormIndex)
    {
        var id, sNode, dNode, temp;
        
        // section title
        id = VOISEditor.BuildSectionTitleId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildSectionTitleId(dFormIndex);
        dNode = document.getElementById(id);
        temp = VOISXml.GetInnerText(dNode);
        VOISXml.ReplaceInnerText(dNode, VOISXml.GetInnerText(sNode));
        VOISXml.ReplaceInnerText(sNode, temp);

        // description
        id = VOISEditor.BuildEnterDescriptionId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildEnterDescriptionId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value.trim();
        dNode.value = sNode.value.trim();
        sNode.value = temp;
        
        // is-main-content values
        id = VOISEditor.BuildIsMainContentId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildIsMainContentId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.selectedIndex;
        dNode.selectedIndex = sNode.selectedIndex;
        sNode.selectedIndex = temp;
        // is-main-content styles
        temp = dNode.parentNode.style.visibility;
        dNode.parentNode.style.visibility = sNode.parentNode.style.visibility;
        sNode.parentNode.style.visibility = temp;
        
        // open with movie values
        id = VOISEditor.BuildOpenWithMovieId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildOpenWithMovieId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.selectedIndex;
        dNode.selectedIndex = sNode.selectedIndex;
        sNode.selectedIndex = temp;
        // open with movie styles
        temp = dNode.parentNode.style.visibility;
        dNode.parentNode.style.visibility = sNode.parentNode.style.visibility;
        sNode.parentNode.style.visibility = temp;
        
        // type hidden
        id = VOISEditor.BuildSelectTypeId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildSelectTypeId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value;
        dNode.value = sNode.value;
        sNode.value = temp;
        
        // condition
        id = VOISEditor.BuildConditiontId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildConditiontId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value;
        dNode.value = sNode.value;
        sNode.value = temp;
        
        
        // only speak at label
        id = VOISEditor.BuildOnlySpeakAtLabelId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildOnlySpeakAtLabelId(dFormIndex);
        dNode = document.getElementById(id);
        temp = VOISXml.GetInnerText(dNode);
        VOISXml.ReplaceInnerText(dNode, VOISXml.GetInnerText(sNode));
        VOISXml.ReplaceInnerText(sNode, temp);
        
        // only speak at
        id = VOISEditor.BuildEnterOnlySpeakAtId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildEnterOnlySpeakAtId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value.trim();
        dNode.value = sNode.value.trim();
        sNode.value = temp;
        
        // never speak at p
        id = VOISEditor.BuildNeverSpeakAtPId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildNeverSpeakAtPId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.style.display;
        dNode.style.display = sNode.style.display;
        sNode.style.display = temp;
        
        // never speak at
        id = VOISEditor.BuildEnterNeverSpeakAtId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildEnterNeverSpeakAtId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value.trim();
        dNode.value = sNode.value.trim();
        sNode.value = temp;
        
        // title at
        id = VOISEditor.BuildEnterTitleAtId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildEnterTitleAtId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value.trim();
        dNode.value = sNode.value.trim();
        sNode.value = temp;
        
        // title
        id = VOISEditor.BuildEnterTitleId(sFormIndex);
        sNode = document.getElementById(id);
        id = VOISEditor.BuildEnterTitleId(dFormIndex);
        dNode = document.getElementById(id);
        temp = dNode.value.trim();
        dNode.value = sNode.value.trim();
        sNode.value = temp;
    },

	SectionRemove : function(formId)
	{
        var sId, i, node;
        
        var ok = confirm("Remove this visual space definition from the form?");
        if (ok)
        {
            VOISEditor.ControlUnSelect();
            i = VOISEditor.formIndexList.indexOf(formId);
            if (i >= 0)
            {
                // remove the node
                sId = VOISEditor.BuildSectionDivId(formId);
                node = document.getElementById(sId);
                node.parentNode.removeChild(node);
                VOISEditor.formIndexList.splice(i, 1);
            }
            if (VOISEditor.formIndexList.length == 0)
            {
                // there are no sections open in the form.
                VOISEditor.formIndex = 0;
            }
            VOISEditor.SectionSetUpDownButtons();
        }
	},
    
    SectionIsTrue : function(formIndex)
    {
        var id;
        var divNode, descriptionNode, conditionNode, titleNode, titleAtNode, onlySpeakAtNode;
        var node;
        var cXpath, tXpath, xXpath;
        var text;
        var cIsTrue, tIsTrue, xIsTrue;
        var i;
        var titleNodeCount;
        var description;
        
        id = VOISEditor.BuildSectionDivId(formIndex);
        divNode = document.getElementById(id);
        id = VOISEditor.BuildEnterDescriptionId(formIndex);
        descriptionNode = document.getElementById(id);
        description = descriptionNode.value;
        id = VOISEditor.BuildConditiontId(formIndex);
        conditionNode = document.getElementById(id);
        id = VOISEditor.BuildEnterTitleId(formIndex);
        titleNode = document.getElementById(id);
        id = VOISEditor.BuildEnterTitleAtId(formIndex);
        titleAtNode = document.getElementById(id);
        id = VOISEditor.BuildEnterOnlySpeakAtId(formIndex);
        onlySpeakAtNode = document.getElementById(id);
        id = VOISEditor.BuildEnterDescriptionId(formIndex);
        
        // the condition must be true
        cXpath = conditionNode.value.trim();
        if (cXpath.length > 0)
        {
            xpathResult = VOISXPath._SingleXpathExpressionIsTrue(cXpath, true);
            if (xpathResult != null)
            {
                cIsTrue = xpathResult.booleanValue;
            }
            else
            {
                cIsTrue = false;
            }
        }
        else
        {
            cIsTrue = true;
        }
        
        // there must be a title
        tXpath = "";
        tIsTrue = false;
        if (cIsTrue)
        {
            text = titleNode.value.trim();
            tIsTrue = text.length > 0;
            
            titleNodeCount = 0;
            tXpath = titleAtNode.value.trim();
            if (tXpath.length > 0)
            {
                xpathResult = VOISXPath._SingleXpathExpressionNodeSet(tXpath, true);
                if (xpathResult != null && xpathResult.snapshotLength > 0)
                {
                    for (i=0; i < xpathResult.snapshotLength; i++ )  
                    {
                        node = xpathResult.snapshotItem(i);
                        id = node.getAttribute("x-awwwe-browser-id");
                        if (id != null && id.length > 0)
                        {
                            titleNodeCount++;
                            if (VOISXml.DeepHasInnerText(node) == true)
                            {
                                tIsTrue = true;
                            }
                        }
                    }
                }
            }
            if (titleNodeCount > 1)
            {
                // probably article which matches a page with a list of articles
                // don't match the article on this page
                // there should be a navigation for this list of articles.
                tIsTrue = false;
            }
        }

        xIsTrue = false;
        xXpath = "";
        if (tIsTrue)
        {
            // there is a title
            // but there must be one or more speak at nodes
            xXpath = onlySpeakAtNode.value.trim();
            xpathResult = VOISXPath._SingleXpathExpressionNodeSet(xXpath, true);
            if (xpathResult != null && xpathResult.snapshotLength > 0)
            {
                for (i=0; i < xpathResult.snapshotLength; i++ )  
                {
                    node = xpathResult.snapshotItem(i);
                    id = node.getAttribute("id");
                    if (id == VOISEditor.wrapperWorkAreaDivId)
                    {
                        // this is equivelent to html/body
                        xIsTrue = true;
                    }
                    else
                    {
                        id = node.getAttribute("x-awwwe-browser-id");
                        if (id.length > 0)
                        {
                            xIsTrue = VOISXml.DeepHasInnerText(node);
                            if (xIsTrue)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        /*
        alert(
            description
            + "\r\n\r\n"
            + cIsTrue.toString() + " " + VOISXPath._CleanXpathExpression(cXpath)
            + "\r\n\r\n"
            + tIsTrue.toString() + " " + VOISXPath._CleanXpathExpression(tXpath)
            + "\r\n\r\n"
            + xIsTrue.toString() + " " + VOISXPath._CleanXpathExpression(xXpath)
        );
        */
        return (cIsTrue && tIsTrue && xIsTrue);
    },
    
    ShowTrueSections : function()
    {
        VOISEditor.ShowTrueFalseSections(true);
    },
    
    ShowFalseSections : function()
    {
        VOISEditor.ShowTrueFalseSections(false);
    },
    
    ShowTrueFalseSections : function(trueFalse)
    {
        // only show sections that are true and only speak at returns some nodes
        var i;
        var formIndex, id;
        var tNode, type;
        var divNode, buttonNode;
        var firstFormIndex, lastFormIndex;
        var haveFirst = false;
        for (i=0; i<VOISEditor.formIndexList.length; i++)
        {
    		formIndex = VOISEditor.formIndexList[i];
            id = VOISEditor.BuildSelectTypeId(formIndex);
            tNode = document.getElementById(id);
            type = tNode.value;
            id = VOISEditor.BuildSectionDivId(formIndex);
            divNode = document.getElementById(id);
            if (VOISEditor.SectionIsTrue(formIndex) == trueFalse)
            {
                // show this section
                divNode.style.display = "block";
                lastFormIndex = formIndex;
                // up botton
                id = VOISEditor.BuildUpSectionButtonId(formIndex);
                buttonNode = document.getElementById(id);
                if (haveFirst == false)
                {
                    haveFirst = true;
                    firstFormIndex = formIndex;
                    // set up button for first section
                    buttonNode.style.display = "none";
                }
                else
                {
                    // set up button for lower sections
                    buttonNode.style.display = "inline-block";
                }
                // show the down button
                id = VOISEditor.BuildDownSectionButtonId(formIndex);
                buttonNode = document.getElementById(id);
                buttonNode.style.display = "inline-block";
            }
            else
            {
                // don't show this section
                divNode.style.display = "none";
            }
        }
        // finally
        // hide the down button for the last section displayed
        if (haveFirst)
        {
            id = VOISEditor.BuildDownSectionButtonId(lastFormIndex);
            buttonNode = document.getElementById(id);
            buttonNode.style.display = "none";
        }
    },
    
    ShowAllSections : function()
    {
        var i, formIndex, id, divNode, buttonNode;
        for (i=0; i<VOISEditor.formIndexList.length; i++)
        {
    		formIndex = VOISEditor.formIndexList[i];
            id = VOISEditor.BuildSectionDivId(formIndex);
            divNode = document.getElementById(id);
            // show this section
            divNode.style.display = "block";
            // up botton
            id = VOISEditor.BuildUpSectionButtonId(formIndex);
            buttonNode = document.getElementById(id);
            // up button
            if (i == 0)
            {
                buttonNode.style.display = "none";
            }
            else
            {
                buttonNode.style.display = "inline-block";
            }
            // down button
            id = VOISEditor.BuildDownSectionButtonId(formIndex);
            buttonNode = document.getElementById(id);
            if (i == VOISEditor.formIndexList.length - 1)
            {
                buttonNode.style.display = "none";
            }
            else
            {
                buttonNode.style.display = "inline-block";
            }
        }
    },

    SectionRemoveAll : function()
    {
        var i, formIndex, id, node;
        for (i=0; i<VOISEditor.formIndexList.length; i++)
        {
    		formIndex = VOISEditor.formIndexList[i];
            id = VOISEditor.BuildSectionDivId(formIndex);
            node = document.getElementById(id);
            // remove the node
            node.parentNode.removeChild(node);
        }
        VOISEditor.formIndexList = [];
        VOISEditor.formIndex = 0;
    },
    
    SectionAddNewArtilcleVisualSpace : function ()
    {
        VOISEditor.SectionAddNew(
            "article",
            "Article Visual Space.",
            "Texts At"
        );
        
    },
    
    SectionAddNewNavigationVisualSpace : function ()
    {
        VOISEditor.SectionAddNew(
            "navigation",
            "Navigation Visual Space.",
            "Links At"
        );
    },
    
    SectionAddNewFormVisualSpace : function ()
    {
        VOISEditor.SectionAddNew(
            "form",
            "Form Visual Space.",
            "Form At"
        );
    },

	SectionAddNew : function(contentTypeArg, sectionTitleArg, onlySpeakAtLabel)
	{
		var control, text, option, div, outerId, innerDiv, upperDiv, id, innerId, p, label;
		div = document.createElement("div");
		outerId = VOISEditor.BuildSectionDivId(VOISEditor.formIndex);
        VOISEditor.formIndexList.push(VOISEditor.formIndex.toString());
		div.setAttribute("id", outerId);
		div.setAttribute("class", VOISEditor.unSelectedDivClassName);
        div.style.display = "block";

        // upper div
        upperDiv = document.createElement("div");
        upperDiv.setAttribute("class", VOISEditor.upperDivClassName);
		div.appendChild(upperDiv);
        
        // section title
        var h5 = document.createElement("h5");
        h5.setAttribute("id", VOISEditor.BuildSectionTitleId(VOISEditor.formIndex));
        var textNode = document.createTextNode(sectionTitleArg);
        h5.appendChild(textNode);
        upperDiv.appendChild(h5);
        

        // new paragraph for the buttons
   		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		upperDiv.appendChild(p);

		// expand button
		// add the open button
		control =  document.createElement("input");
		control.setAttribute("type", "button");
		control.value = "Expand This Section.";
		id = VOISEditor.BuildExpandSectionButtonId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'click',
            function()
            {
                VOISEditor.SectionExpand(VOISEditor.ExtractSectionIndexFromId(this.id));
            },
            false
        );
		p.appendChild(control);
		upperDiv.appendChild(p);

		// un expand button
		// add the open button
		control =  document.createElement("input");
		control.setAttribute("type", "button");
		control.value = "Shrink This Section.";
		id = VOISEditor.BuildUnExpandSectionButtonId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.style.visibility = "hidden";
        control.addEventListener(
            'click',
            function()
            {
                VOISEditor.SectionUnExpand(VOISEditor.ExtractSectionIndexFromId(this.id));
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		p.appendChild(control);

		// remove button
		// add the remove button
		control =  document.createElement("input");
        id = VOISEditor.BuildRemoveSectionButtonId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("type", "button");
		control.value = "Remove This Visual Space Definition.";
        control.addEventListener(
            'click',
            function()
            {
                VOISEditor.SectionRemove(VOISEditor.ExtractSectionIndexFromId(this.id));
            },
            false
        );
		p.appendChild(control);
        
        // up button
		control =  document.createElement("input");
		control.setAttribute("type", "button");
		control.value = "Move Up";
		id = VOISEditor.BuildUpSectionButtonId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'click',
            function()
            {
                VOISEditor.SectionUp(VOISEditor.ExtractSectionIndexFromId(this.id));
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		p.appendChild(control);
        
        // down button
		control =  document.createElement("input");
		control.setAttribute("type", "button");
		control.value = "Move Down";
		id = VOISEditor.BuildDownSectionButtonId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'click',
            function()
            {
                VOISEditor.SectionDown(VOISEditor.ExtractSectionIndexFromId(this.id));
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		p.appendChild(control);

        // new paragraph for the comments
   		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		upperDiv.appendChild(p);

		// add the comment
		control = document.createElement("textarea");
		id = VOISEditor.BuildEnterDescriptionId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("class", "awwwe-browser-vois-wizard-form-section-comment");
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
        label = VOISEditor.Label(id, "Description")
		p.appendChild(label);
		p.appendChild(control);
		upperDiv.appendChild(p);
        
        // new paragraph for main content
   		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
        p.style.visibility = "visible";
		upperDiv.appendChild(p);

        // add main content select
		control = document.createElement("select");
		id = VOISEditor.BuildIsMainContentId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		option = document.createElement("option");
		option.text = "This is main content.";
		option.value = "true";
        option.selected = true;
		control.add(option,null);
		option = document.createElement("option");
		option.text = "This is not main content.";
		option.value = "false";
        option.selected = false;
		control.add(option,null);
        label = VOISEditor.Label(control.getAttribute("id"), "Main Conent.");
		p.appendChild(label);
		p.appendChild(control);
        
        // new paragraph for open with movie
   		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
        p.style.visibility = (contentTypeArg == "article") ? ("visible") : ("hidden");
		upperDiv.appendChild(p);

        // add open the web page with a movie select
		control = document.createElement("select");
		id = VOISEditor.BuildOpenWithMovieId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		option = document.createElement("option");
		option.text = "Open the web page with this article.";
		option.value = "false";
        option.selected = true;
		control.add(option,null);
		option = document.createElement("option");
		option.text = "Open the web page with the first movie in the article.";
		option.value = "true";
        option.selected = false;
		control.add(option,null);
        label = VOISEditor.Label(control.getAttribute("id"), "Opening the web page.");
		p.appendChild(label);
		p.appendChild(control);

		// add the type
		control = document.createElement("text");
		id = VOISEditor.BuildSelectTypeId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.setAttribute("type", "hidden");
        control.value = contentTypeArg; // ("navigation", "article", "form")
		p.appendChild(control);

        // add the inner div
		innerDiv = document.createElement("div");
		innerId = VOISEditor.BuildSectionInnerDivId(VOISEditor.formIndex);
		innerDiv.setAttribute("id", innerId);
		innerDiv.setAttribute("class", VOISEditor.unSelectedInnerDivClassName);
        div.appendChild(innerDiv);
        
        // add the condition
        control = document.createElement("textarea");
        id = VOISEditor.BuildConditiontId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("class", "awwwe-browser-vois-wizard-form-section-titleat");
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_YesPaste(this.id, true);
                VOISEditor.ControlSelect_SetToCondition();
            },
            false
        );
		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		p.appendChild(VOISEditor.Label(id, "Condition"));
		p.appendChild(control);
		innerDiv.appendChild(p);

		// add the title at
		control = document.createElement("textarea");
		id = VOISEditor.BuildEnterTitleAtId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("class", "awwwe-browser-vois-wizard-form-section-titleat");
        control.addEventListener(
            'focus',
            function()
            {
                if (VOISEditor.alerting == false)
                {
                    VOISEditor.ControlSelect_YesPaste(this.id, false);
                    VOISEditor.ControlSelect_SetToTitleAt();
                }
            },
            false
        );
		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		p.appendChild(VOISEditor.Label(id, "Title At"));
		p.appendChild(control);
		innerDiv.appendChild(p);

		// add the title
		control = document.createElement("input");
		control.setAttribute("type", "text");
		id = VOISEditor.BuildEnterTitleId(VOISEditor.formIndex);
		control.setAttribute("id", id);
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_NoPaste(this.id);
            },
            false
        );
		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		p.appendChild(VOISEditor.Label(id, "Title"));
		p.appendChild(control);
		innerDiv.appendChild(p);

		// add the only speak at
		control = document.createElement("textarea");
		id = VOISEditor.BuildEnterOnlySpeakAtId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("class", "awwwe-browser-vois-wizard-form-section-onlyspeakat");
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_YesPaste(this.id, false);
                VOISEditor.ControlSelect_SetToOnlySpeakAt();
            },
            false
        );
		p = document.createElement("p");
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
        var label = VOISEditor.Label(control.getAttribute("id"), onlySpeakAtLabel);
        label.setAttribute("id", VOISEditor.BuildOnlySpeakAtLabelId(VOISEditor.formIndex));
		p.appendChild(label);
		p.appendChild(control);
		innerDiv.appendChild(p);

		// add the never speak at
		var control = document.createElement("textarea");
		id = VOISEditor.BuildEnterNeverSpeakAtId(VOISEditor.formIndex);
		control.setAttribute("id", id);
		control.setAttribute("class", "awwwe-browser-vois-wizard-form-section-neverspeakat");
        control.addEventListener(
            'focus',
            function()
            {
                VOISEditor.ControlSelect_YesPaste(this.id, false);
                VOISEditor.ControlSelect_SetToNeverSpeakAt();
            },
            false
        );
		p = document.createElement("p");
		id = VOISEditor.BuildNeverSpeakAtPId(VOISEditor.formIndex);
        p.setAttribute("id", id);
        p.setAttribute("class", VOISEditor.unSelectedControlClassName);
		p.appendChild(VOISEditor.Label(control.getAttribute("id"), "Never Speak At"));
		p.appendChild(control);
        if (contentTypeArg == "form")
        {
            p.style.display = "none";
        }
        else
        {
            p.style.display = "block";
        }
		innerDiv.appendChild(p);

        var page = document.getElementById("awwwe-browser-vois-wizard-form-form-tab-page");
        page.appendChild(div);

        VOISEditor.formIndex++;
        VOISEditor.SectionSetUpDownButtonsAtEnd();
        
        // scroll to the bottom of the page
        window.scrollTo(0, document.body.scrollHeight);
	},
    
	ControlSelect_NoPaste : function (id)
	{
        // use a control which won't get xpaths dumped to it

        // turn off the currently border highlighting of xpaths in the web page.
        VOISXPath.XPathHighlightWebPageUndo();

		var node = document.getElementById(id);
		if (VOISEditor.currentlySelectedNode != null)
		{
            // the paragraph
			VOISEditor.currentlySelectedNode.parentNode.setAttribute("class", VOISEditor.unSelectedControlClassName);
            // the div outside the div outside the paragraph
            if (node.parentNode.parentNode.parentNode != VOISEditor.currentlySelectedNode.parentNode.parentNode.parentNode)
            {
			    VOISEditor.currentlySelectedNode.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
        		node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
            }
		}
        else if (VOISEditor.currentlyUsedNode != null)
        {
            // the div outside the div outside the paragraph
            if (node.parentNode.parentNode.parentNode != VOISEditor.currentlyUsedNode.parentNode.parentNode.parentNode)
            {
			    VOISEditor.currentlyUsedNode.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
        		node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
            }
        }
        else if (VOISEditor.currentlySelectedNode == null && VOISEditor.currentlyUsedNode == null)
        {
            // the div outside the div outside the paragraph
            node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
        }
        VOISFloater._UnInformUser();
        // the paragraph
		node.parentNode.setAttribute("class", VOISEditor.unSelectedControlClassName);
		VOISEditor.currentlySelectedNode = null;
        VOISEditor.currentlyUsedNode = node;
        
        // set the floater option for only speak at
        var divId = node.parentNode.parentNode.parentNode.getAttribute("id");
        var index = VOISEditor.BuildFormIndexFromSectionDivId(divId);
        var id = VOISEditor.BuildOnlySpeakAtLabelId(index);
        node = document.getElementById(id);
        var text = VOISXml.GetInnerText(node);
        VOISFloater.SetOnlySpeakAtOption(text);
	},
    
    ControlSelect_SetToCondition : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathSelectId);
        node.selectedIndex = -1;
        node.selectedIndex = 0;
        node.onchange();
        // show the enter xpath enter textarea
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.visibility = "visible";
        // hide the sayas text enter area
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
    },
    
    ControlSelect_SetToTitleAt : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathSelectId);
        node.selectedIndex = -1;
        node.selectedIndex = 1;        
        node.onchange();
        // show the enter xpath enter textarea
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.visibility = "visible";
        // hide the sayas text enter area
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
    },
    
    ControlSelect_SetToOnlySpeakAt : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathSelectId);
        node.selectedIndex = -1;
        node.selectedIndex = 2;        
        node.onchange();
        // show the enter xpath enter textarea
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.visibility = "visible";
        // hide the sayas text enter area
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
    },
    
    ControlSelect_SetToNeverSpeakAt : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathSelectId);
        node.selectedIndex = -1;
        node.selectedIndex = 3;        
        node.onchange();
        // show the enter xpath enter textarea
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.visibility = "visible";
        // hide the sayas text enter area
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
    },
    
    ControlSelect_UserSelectFromWebPage : function()
    {
        var id;
        var node, button;
        
        // get the xpath selection (title at, only speak at, never speak at)
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (node.selectedIndex == 0)
        {
            // condition selected
            VOISXPath.convertXPathToCount = true;
            id = VOISEditor.BuildConditiontId(VOISEditor.currentlySelectedFormIndex);
            VOISEditor.ControlSelect_YesPaste(id, true);
            // do not highlight the xpath in the web page
            // as the xpath is a boolean
            VOISXPath.XPathHighlightWebPageUndo();
            // set the highlight, test buttons
            button = document.getElementById(VOISFloater.infoXPathTestButtonId);
            button.style.display = "inline";
            button = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            button.style.display = "none";
        }
        else if (node.selectedIndex == 1)
        {
            // title at selected
            VOISXPath.convertXPathToCount = false;
            id = VOISEditor.BuildEnterTitleAtId(VOISEditor.currentlySelectedFormIndex);
            VOISEditor.ControlSelect_YesPaste(id, false);
            // highlight the xpath nodes in the web page
            id = VOISEditor.BuildEnterTitleAtId(VOISEditor.currentlySelectedFormIndex);
            VOISXPath.XPathHighlightWebPage(id);
            // set the highlight, test buttons
            button = document.getElementById(VOISFloater.infoXPathTestButtonId);
            button.style.display = "none";
            button = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            button.style.display = "inline";
        }
        else if (node.selectedIndex == 2)
        {
            // only speak at selected
            VOISXPath.convertXPathToCount = false;
            id = VOISEditor.BuildEnterOnlySpeakAtId(VOISEditor.currentlySelectedFormIndex);
            VOISEditor.ControlSelect_YesPaste(id, false);
            // highlight the xpath nodes in the web page
            id = VOISEditor.BuildEnterOnlySpeakAtId(VOISEditor.currentlySelectedFormIndex);
            VOISXPath.XPathHighlightWebPage(id);
            // set the highlight, test buttons
            button = document.getElementById(VOISFloater.infoXPathTestButtonId);
            button.style.display = "none";
            button = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            button.style.display = "inline";
        }
        else if (node.selectedIndex == 3)
        {
            // never speak at selected
            VOISXPath.convertXPathToCount = false;
            id = VOISEditor.BuildEnterNeverSpeakAtId(VOISEditor.currentlySelectedFormIndex);
            VOISEditor.ControlSelect_YesPaste(id, false);
            // highlight the xpath nodes in the web page
            id = VOISEditor.BuildEnterNeverSpeakAtId(VOISEditor.currentlySelectedFormIndex);
            VOISXPath.XPathHighlightWebPage(id);
            // set the highlight, test buttons
            button = document.getElementById(VOISFloater.infoXPathTestButtonId);
            button.style.display = "none";
            button = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            button.style.display = "inline";
        }
        VOISFloater._InformUser();
    },
    
	ControlSelect_YesPaste : function (id, xPathToCount)
	{
        var divId;
        VOISXPath.convertXPathToCount = xPathToCount;
		var node = document.getElementById(id);
		if (VOISEditor.currentlySelectedNode != null)
		{
			VOISEditor.currentlySelectedNode.parentNode.setAttribute("class", VOISEditor.unSelectedControlClassName);
            // the div outside the div outside the paragraph
            if (node.parentNode.parentNode.parentNode != VOISEditor.currentlySelectedNode.parentNode.parentNode.parentNode)
            {
    			VOISEditor.currentlySelectedNode.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
        		node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
            }
		}
        else if (VOISEditor.currentlyUsedNode != null)
        {
            // the div outside the div outside the paragraph
            if (node.parentNode.parentNode.parentNode != VOISEditor.currentlyUsedNode.parentNode.parentNode.parentNode)
            {
			    VOISEditor.currentlyUsedNode.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
        		node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
            }
        }
        else if (VOISEditor.currentlySelectedNode == null && VOISEditor.currentlyUsedNode == null)
        {
            // the div outside the div outside the paragraph
            node.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.selectedDivClassName);
        }
        divId = node.parentNode.parentNode.parentNode.getAttribute("id");
        VOISEditor.currentlySelectedFormIndex = VOISEditor.BuildFormIndexFromSectionDivId(divId);

        // the paragraph outide the label and input
		node.parentNode.setAttribute("class", VOISEditor.selectedControlClassName);
		VOISEditor.currentlySelectedNode = node;
        VOISEditor.currentlyUsedNode = null;
        
        // at the floater, set the label for 'only speak at'
        var id = VOISEditor.BuildOnlySpeakAtLabelId(VOISEditor.currentlySelectedFormIndex);
        node = document.getElementById(id);
        var text = VOISXml.GetInnerText(node);
        VOISFloater.SetOnlySpeakAtOption(text);
    },

	ControlUnSelect : function ()
	{
		if (VOISEditor.currentlySelectedNode != null)
		{
            if (VOISEditor.currentlySelectedNode.parentNode != null)
            {
                // the paragraph
	    		VOISEditor.currentlySelectedNode.parentNode.setAttribute("class", VOISEditor.unSelectedControlClassName);
                if (VOISEditor.currentlySelectedNode.parentNode.parentNode != null)
                {
                    // the div outside the div outside the paragraph
                    VOISEditor.currentlySelectedNode.parentNode.parentNode.parentNode.setAttribute("class", VOISEditor.unSelectedDivClassName);
                }
            }
		}
		VOISEditor.currentlySelectedNode = null;
	},

	OnLoad : function ()
	{
        var node;
        VOISEditor.form = document.getElementById(VOISEditor.formId);
		VOISEditor.SetUpMarkup();
        VOISXml.XmlToForm();
        
        node = document.getElementById(VOISEditor.loadingSectionId);
        node.style.display = "none";
        node = document.getElementById(VOISEditor.loadedSectionId);
        node.style.display = "block";
	},
	
	SetUpMarkup : function()
	{
		var i;
		var node = document.getElementById(VOISEditor.wrapperWorkAreaDivId);
        if (node)
        {
		    VOISEditor.SetUpMarkupNode(node);
        }
	},

    SetUpMarkupNode : function(node)
	{
        // set styles for display of the web page blocks.
		var i, name, alerted;
        var pNode;
        name = node.localName.toLowerCase();
        i = name.indexOf(":");
        if (i >= 0)
        {
            i++;
            name = name.substring(i);
        }
        if (name.length == 0)
        {
            return;
        }
        if (name != "br" && name != "hr")
        {
            if (
                name == "form"
            )
            {
                node.style.display = "block";
                node.style.margin = "10px";
            }
            else if (
                name == "a"
                || name == "img"
                || name == "b"
                || name == "em"
                || name == "strong"
                || name == "i"

                || name == "basefont"
                || name == "font"

                || name == "bdo"
                || name == "u"
                || name == "q"
                || name == "s"
                || name == "samp"
                || name == "small"
                || name == "span"
                || name == "strike"
                || name == "sub"
                || name == "sup"
                || name == "var"
            )
            {
                node.style.display = "inline-block";
                node.style.margin = "10px";
            }
            else if (typeof(node.style) != undefined)
            {
                node.style.display = "block";
                node.style.margin = "10px";
                node.style.clear = "both";
            }
            if (name == "a")
            {
                node.setAttribute("onclick", "return false;");
                node.addEventListener("click", function(e){VOISFloater.InformUserOpen(e);}, false);
                node.addEventListener('mouseover', function(e){VOISFloater.InformUser(e);}, false);
                node.style.cursor = "pointer";
                node.style.borderStyle = "dotted";
            }
            else if (name == "video")
            {
                node.addEventListener("click", function(e){VOISFloater.InformUserOpen(e); return false;}, false);
                node.addEventListener('mouseover', function(e){VOISFloater.InformUser(e);}, false);
                node.style.cursor = "crosshair";
                node.style.borderStyle = "dashed";
            }
            else
            {
                node.addEventListener("click", function(e){VOISFloater.InformUserOpen(e); return false;}, false);
                node.addEventListener('mouseover', function(e){VOISFloater.InformUser(e);}, false);
                node.style.cursor = "crosshair";
                node.style.borderStyle = "solid";
            }
            //node.setAttribute("onmouseover", "VOISFloater.InformUser(event);");
            // node.onmouseover = "VOISFloater.InformUser(e)";
            // node.style.position = "relative";
            node.style.position = "static";
            node.style.width = "auto";
            node.style.height = "auto";
            node.style.padding = "10px";
            node.style.borderWidth = "2px";
            node.style.borderColor = "green";
            node.style.backgroundColor = "#ffffff";

		    for (i=0; i<node.childNodes.length; i++)
		    {
			    if (node.childNodes[i].nodeType == 1 && node.childNodes[i].style)
			    {
                    
				    VOISEditor.SetUpMarkupNode(node.childNodes[i]);
			    }
            }
		}
	}

};
